import hcQuest.HCQ;
import hcQuest.HCQ_Interface;

import java.awt.Font;
import java.awt.GridBagLayout;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JFrame;
import javax.swing.JTextArea;
import javax.swing.Timer;

public class HCQ_Application extends JFrame implements HCQ_Interface {

    private static final long serialVersionUID = 1L;

    public static void main(String[] args) {
	new HCQ_Application();
    }

    private HCQ hcqPanel;

    public HCQ_Application() {

	final String lang = "english";
	/** default language **/
	final String exp = "LabVersion";
	final boolean askInitals = true;
	final String appTitle = HCQ.VERSION + ": Hand Counting Questionnaire";

	setLayout(new GridBagLayout());

	hcqPanel = new HCQ(true, this, this.getClass(), lang, exp, askInitals);
	hcqPanel.setPreferredSize(hcqPanel.getSize()); // need for layout
	// manager
	add(hcqPanel);
	// pack();

	getContentPane().setBackground(hcqPanel.getBackground());
	setSize(Toolkit.getDefaultToolkit().getScreenSize());
	setResizable(false);
	setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	// setMinimumSize(hcqPanel.getSize());
	// this.setAlwaysOnTop(true);
	setTitle(appTitle);
	setVisible(true);
    }

    public void quitApplication() {
	hcqPanel.setVisible(false);
	getContentPane().removeAll();

	JTextArea txt = new JTextArea(hcqPanel.l.endText);
	/** translate */
	txt.setFont(new Font("Arial", Font.BOLD, 26));
	add(txt);
	repaint();
	ActionListener AL = new ActionListener() {
	    public void actionPerformed(ActionEvent evt) {
		System.exit(0);
	    }
	};
	new Timer(1000, AL).start();

    }

}
